package com.bruip.spring.process;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @author 王若龙
 * @CreateTime 2022-08-31 16:06
 */
public class MyBeanPostProcess implements BeanPostProcessor {

    /**
     * 在初始化之前
     *
     * @param bean     豆
     * @param beanName bean名字
     * @return {@link Object}
     * @throws BeansException 豆子例外
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("后置处理器的初始化之前");
        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    /**
     * 发布过程初始化后
     *
     * @param bean     豆
     * @param beanName bean名字
     * @return {@link Object}
     * @throws BeansException 豆子例外
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("后置处理器的初始化后");
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
